package com.jt.entity;

import lombok.Data;

/**
 * Created by Administrator on 2017/4/7.
 */
@Data
public class Response<T> {

    public Response(String status, String message, T responseText) {
        this.status = status;
        this.message = message;
        this.responseText = responseText;
    }

    private String status;
    private String message;
    private T responseText;

    private enum Status {

        SUCCESS("success"), ERROR("error");

        private String status;

        Status(String status) {
            this.status = status;
        }

        public String getStatus() {
            return status;
        }
    }


    /**
     * success
     *
     * @param responseText
     * @param <T>
     * @return
     */
    public static <T> Response success(T responseText) {
        return new Response(Status.SUCCESS.getStatus(), "处理成功！", responseText);
    }

    /**
     * error
     *
     * @param responseText
     * @param <T>
     * @return
     */
    public static <T> Response error(T responseText) {
        return new Response(Status.ERROR.getStatus(), "处理失败！", responseText);
    }

}
